﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using GtsServer.Common;

namespace GtsServer.DAL
{
    public class NewDeliveryInfoDAL
    {
        public NewDeliveryInfoDAL() { }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(GtsServer.Model.NewDeliveryInfoMould model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into NewDeliveryInfo(");
            strSql.Append("NewDeliveryID,UserID,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@NewDeliveryID,@UserID,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@NewDeliveryID", SqlDbType.Int,4),
					new SqlParameter("@UserID", SqlDbType.Int,4),
					new SqlParameter("@CreateTime", SqlDbType.DateTime)};
            parameters[0].Value = model.NewDeliveryID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.CreateTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        public DataSet GetNewDeliveryInfo(string userAccount)
        {
            IDataParameter[] parms = new IDataParameter[]{ 
                new SqlParameter("@userAccount",userAccount)
            };
            DataSet ds = DbHelperSQL.RunProcedure("GetNewDeliveryInfo", parms, "GetNewDeliveryInfo");
            return ds;
        }

    }
}
